/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package POS.Interface;

import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
 
public class MenuPane extends JPanel {
    public MenuPane() {       
        /**
        * Creates 1x1 Grid Layout
        * Intentions to use a 2x1 to have an order screen that allows the user to 
        * view what they're ringing in.
        */
        super(new GridLayout(1, 1));
        
        // Variables. Creates all of the Panels and the TabbedPane.
        JTabbedPane tabbedPane = new JTabbedPane();
        JComponent bevPanel;
        JComponent entreesPanel;
        JComponent dessertsPanel;
        JComponent sidesPanel;
        JComponent addExtraPanel;
        JComponent combosPanel;
        
        /**
         * Sets up the way the tabbed pane looks. Buttons on left alignment
         * with wrapped tabs.
         */
        tabbedPane.setTabPlacement(JTabbedPane.LEFT);
        tabbedPane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
        
        /**
         * Creates the panel, tab, mnemonics, and tooltips for the various tabs
         * within the program
         */
        bevPanel = makeTextPanel("This is where beverages go. Will put buttons etc"
                + "in this panel");
        // adds the tab and bevPanel to the tabbed pane
        tabbedPane.addTab("Beverages", bevPanel);
        // connects a quick tab switch using the B key
        tabbedPane.setMnemonicAt(0, KeyEvent.VK_B);
        // sets a basic tooltip
        tabbedPane.setToolTipText("Beverages");

        entreesPanel = makeTextPanel("This is where solo entrees go");
        tabbedPane.addTab("Entrees", entreesPanel);
        tabbedPane.setMnemonicAt(1, KeyEvent.VK_E);
        tabbedPane.setToolTipText("Entrees");
        
        dessertsPanel = makeTextPanel("This is where desserts go");
        tabbedPane.addTab("Desserts", dessertsPanel);
        tabbedPane.setMnemonicAt(2, KeyEvent.VK_D);
        tabbedPane.setToolTipText("Desserts");
        
        sidesPanel = makeTextPanel("This is where sides go");
        tabbedPane.addTab("Sides", sidesPanel);
        tabbedPane.setMnemonicAt(3, KeyEvent.VK_S);
        tabbedPane.setToolTipText("Sides");
        
        addExtraPanel = makeTextPanel("This is where addons go ex: extra patty"
                + "on burger.");
        tabbedPane.addTab("Add/Extra", addExtraPanel);
        tabbedPane.setMnemonicAt(4, KeyEvent.VK_A);
        tabbedPane.setToolTipText("Add/Extra");
        
        combosPanel = makeTextPanel("This is where basic combos/specials can go. /n"
                + "Made this simply just in case we wanted it.");
        tabbedPane.addTab("Combos", combosPanel);
        tabbedPane.setMnemonicAt(5, KeyEvent.VK_C);
        tabbedPane.setToolTipText("Combos");
        
        // adds the tabbedPane to the overall Panel
        add(tabbedPane);
         
    }
    /**
     * Very basic panel. Currently being used as a placeholder for the buttons
     * on the menu.
     */ 
    protected final JComponent makeTextPanel(String text) {
        JPanel panel = new JPanel(false);
        JLabel filler = new JLabel(text);
        filler.setHorizontalAlignment(JLabel.CENTER);
        panel.setLayout(new GridLayout(1, 1));
        panel.add(filler);
        return panel;
    }

    /**
     * Create the GUI and show it.  
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("TabbedPaneDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         
        //Add content to the window.
        frame.add(new MenuPane(), BorderLayout.CENTER);
         
        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }
     
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
        createAndShowGUI();
            }
        });
    }
}